/**
 * Created by Juvid on 2017/3/21.
 */
//常用网络请求
import React, { Component } from 'react';

export default class JuNetResquest extends Component{
    getDataFromFetchs() {
        fetch('http://gank.io/api/search/query/listview/category/福利/count/10/page/1',{

        })//请求地址
            .then((response) => response.json())//取数据
            .then((responseJson) => {//处理数据
                //通过setState()方法重新渲染界面
                console.log("返回",responseJson.results);

            })
            .catch((error) => {
                console.warn('失败',error);
            }).done();
    }
//三方网络请求
    httpRequest(){
        var request = new XMLHttpRequest();
        request.onreadystatechange = (e) => {
            if (request.readyState !== 4) {
                return;
            }
            if (request.status === 200) {
                console.log('成功', request.responseText);
            } else {
                console.warn('error');
            }
        };
        request.open('GET', 'http://gank.io/api/search/query/listview/category/福利/count/10/page/1');
        request.send();
    }
    test(){
        console.log("返回");
    }

}
// module.exports = JuResquest;
